/*
 * 文件名：UserDaoImpl.java
 * 版权：Copyright 2007-2015 517na Tech. Co. Ltd. All Rights Reserved. 
 * 描述： UserDaoImpl.java
 * 修改人：yanshu
 * 修改时间：2015年12月21日
 * 修改内容：新增
 */
package com.feichuang.chineseWoodCarving.dao.impl;

import org.springframework.stereotype.Component;

import com.feichuang.chineseWoodCarving.dao.IUserDao;
import com.feichuang.chineseWoodCarving.interceptor.BeanUtils;
import com.feichuang.chineseWoodCarving.model.DataModel;
import com.feichuang.chineseWoodCarving.model.MUser;

/**
 * TODO 添加类的一句话简单描述.
 * <p>
 * TODO 详细描述
 * <p>
 * TODO 示例代码
 * 
 * <pre>
 * </pre>
 * 
 * @author yanshu
 */
@Component("userDao")
public class UserDaoImpl extends BaseDaoImpl implements IUserDao {

    /**
     * {@登录}.
     */
    @Override
    public MUser login(String userName, String passWord, int userType) {
        MUser user = new MUser();
        user.setUserName(userName);
        user.setLoginPassword(passWord);
        user.setUserType(userType);
        DataModel<MUser> dataModel = new DataModel<MUser>("", user);
        return this.sqlSession.selectOne("com.feichuang.chineseWoodCarving.dao.IUserDao.login", dataModel);
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean insertUser(MUser user) {
        // 空值填充
        BeanUtils.notNull(user);
        DataModel<MUser> dataModel = new DataModel<MUser>("", user);
        this.sqlSession.insert("com.feichuang.chineseWoodCarving.dao.IUserDao.insert", dataModel);
        return true;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public MUser selectUserByUserNo(String userNo) {

        return this.sqlSession.selectOne("com.feichuang.chineseWoodCarving.dao.IUserDao.selectUserByUserNo", userNo);
    }

}
